package com.cetcs.kmga.dataManager.controller;

import com.cetcs.kmga.common.BaseController;
import com.cetcs.kmga.common.BaseResponse;
import com.cetcs.kmga.common.Constant;
import com.cetcs.kmga.dataManager.annotation.LogAnnotation;
import com.cetcs.kmga.dataManager.entity.dataManager.vo.MultiLineChartVo;
import com.cetcs.kmga.dataManager.entity.dataManager.vo.ResourceRiskEventVo;
import com.cetcs.kmga.dataManager.entity.global.LogLevelEnum;
import com.cetcs.kmga.dataManager.entity.global.LogTypeEnum;
import com.cetcs.kmga.dataManager.service.dataManager.ResourceStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 资源概览统计控制层
 *
 * @author xutao
 * @version V1.0 创建时间：2017-10-25 13:40
 *          Copyright 2017 by CETC
 */
@RestController
@RequestMapping("/resourceStat")
public class ResourceStatController extends BaseController {

    @Autowired
    private ResourceStatService resourceStatService;

    /**
     * 统计资源当天的运行总量情况
     *
     * @return
     */
    @LogAnnotation(module = "数据监管-资源状态", logType = LogTypeEnum.业务日志, description = "统计资源当天的运行总量情况", logLevel = LogLevelEnum.低)
    @RequestMapping(value = "/statResourceCurrentDayRunTimeTotal", method = RequestMethod.GET)
    public BaseResponse statResourceCurrentDayRunTimeTotal() {
        try {

            Map<String, Object> result = resourceStatService.statResourceCurrentDayRunTimeTotal();
            return this.ok(result);
        } catch (Exception e) {
            e.printStackTrace();
            return this.error(Constant.SYSTEM_EXCEPTION);
        }
    }


    /**
     * 统计资源当天的运行详情
     *
     * @return
     */
    @LogAnnotation(module = "数据监管-资源状态", logType = LogTypeEnum.业务日志, description = "统计资源当天的运行详情", logLevel = LogLevelEnum.低)
    @RequestMapping(value = "/statResourceCurrentDayRunTimeDetail", method = RequestMethod.GET)
    public BaseResponse statResourceCurrentDayRunTimeDetailGroupByResrcId() {
        try {

            List<Map<String, Object>> result = resourceStatService.statResourceCurrentDayRunTimeDetailGroupByResrcId();
            return this.ok(result);
        } catch (Exception e) {
            e.printStackTrace();
            return this.error(Constant.SYSTEM_EXCEPTION);
        }
    }


    /**
     * 获取最新15条日志信息
     *
     * @return
     */
    @LogAnnotation(module = "数据监管-资源状态", logType = LogTypeEnum.业务日志, description = "获取最新15条日志信息", logLevel = LogLevelEnum.低)
    @RequestMapping(value = "/findNewlyRiskEvent", method = RequestMethod.GET)
    public BaseResponse findNewlyRiskEvent() {
        try {

            List<ResourceRiskEventVo> result = resourceStatService.findNewlyRiskEvent();
            return this.ok(result);
        } catch (Exception e) {
            e.printStackTrace();
            return this.error(Constant.SYSTEM_EXCEPTION);
        }
    }
}
